<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<title>二手商品总览</title>
	<meta charset="UTF-8"/>
	<link rel="stylesheet" type="text/css" href="/css/goods.css"/>
	<script type="text/javascript" src="/js/jquery-3.2.js"></script>
	<script type="text/javascript">
		$(function (){
			$('.searchBtn').click(function (){
				var Keyword = $('.searchIn')[0].value;
				//if (Keyword != null)
				window.location.href='/goToSearch.do?Keywords='+Keyword;
				window.event.returnValue=false;
				//console.log(window.location);
			});
		})
	</script>
	<script type="text/javascript">
		$(function(){
			//菜单特效
			var index = 0
			$("#goods-menu-toggle").on("click",function(){
				if (index ===0 ) {
					$("#goods-menu").css("left","1px");
					$(this).css("left","178px");
					index =1;
				}else{
					$("#goods-menu").css("left","-180px");
					$(this).css("left","1px");
					index=0;
				}
			});

			//点击菜单，对应类别颜色加深
			$(".goods-class li").on("click",function(){
				//加粗当前点击的li
				$(this).css("font-weight","600").siblings("li").css("font-weight","500");
			});

		})
	</script>
	<script>
		$(function ()
		{
			$('.goods-buy').click(function ()
			{
				var id = $(this).attr('value');
				window.location.href = "/goToProductDetail.do?GID="+id;
			});

			$("#next_page").click(function ()
			{
				var pages = parseInt($(this).attr("value"));
				pages += 12;
				console.log(pages);
				window.location.href = "/changePage.do?pages="+pages.toString();
			})

			$("#last_page").click(function ()
			{
				var pages = parseInt($(this).attr("value"));
				pages -= 12;
				window.location.href = "/changePage.do?pages="+pages.toString();
			})
		});
	</script>
</head>
<body>

	<!-- 导航 -->
	<header class="navbar">
		<div class="nav-info">
			<!--			<a class="username" href="information.html">用户</a>-->
			<a href="/login.do" th:if="${marketUser}==null" class="username">用户</a>
			<a href="/personal_info.do" th:if="${marketUser}!=null" th:text="${marketUser.uname}"></a>
			<!--			<a class="goodsshelf" href="register1.html">||&nbsp;&nbsp;&nbsp;注册</a>-->
			<a class="goodshelf" href="/login.do" th:if="${marketUser}==null">||&nbsp;&nbsp;&nbsp;我的购物车</a>
			<a class="goodshelf" href="/goToMyCart.do" th:if="${marketUser}!=null">||&nbsp;&nbsp;&nbsp;我的购物车</a>
			<a class="logout" href="#" th:if="${marketUser}==null">[ 退 出 ]</a>
			<a class="logout" href="/logout.do" th:if="${marketUser}!=null">[ 退 出 ]</a>
		</div> <!-- nav-info -->
		<form class="nav-search">
			<a href="/"><img class="logo" src="/image/title.jpg"/></a>
			<div class="search-form">
				<a class="search-logo">| &nbsp;<img src="/image/search.png"/></a>
				<input type="text" class="searchIn" th:value="${Keywords}" placeholder="搜二手物品..."/>
				<input type="submit" class="searchBtn" value="搜索"/>
			</div>
		</form><!--  nav-search -->
		<ul class="menu">
			<li><a href="/">首页</a></li>
			<li><a class="active" href="/goToMallPage.do">二手商品</a></li>
<!--			<li><a href="request.html">求购区</a></li>-->
		</ul>			
	</header>

	<!-- 图书分类 -->
	<div id="container">
		<div id="goods-menu">
			<h4>物品分类</h4>
			<ul class="goods-class">
				<li><a href="/goToSearch.do?Keywords=书" title="二手书籍">书籍</a></li>
				<li><a href="/goToSearch.do?Keywords=床上用品" title="床上用品">床上用品</a></li>
				<li><a href="/goToSearch.do?Keywords=学习用品" title="学习用品">学习用品</a></li>
				<li><a href="/goToSearch.do?Keywords=日用品" title="日用品">日用品</a></li>
			</ul>
		</div>
        <div id="goods-menu-toggle">
			查 看 菜 单
			<div id="toggle-btn"></div>
		</div>
		<div id="goods-container">
			<h3 class="goods-title"><a href="#">| 所有二手商品</a></h3>
			<ul class="goods-lists">
				<figure class="goods-list" th:each="o:${marketGoodsList}">
					<a href="#" class="goods-pic">
<!--						<img src="/img/1.jpg" th:src="${o.getGID()}"/>-->
						<img src="/image/book.jpg"/>
					</a>
					<a href="#" class="goods-info">
						<h5 class="goods-name" th:text="${o.getName()}">计算机组成原理</h5>
						<span class="goods-detail" th:text="'种类:' + ${o.getKind()}+' | '+ '数量:' + ${o.getNumber()}"></span>
<!--						<span class="goods-detail" th:text="'数量'+${o.getNumber()}"></span>-->
						<h5 class="goods-price" th:text="'￥'+${o.getPrice()}">999</h5>
					</a>
					<span>
						<a href="#" class="goods-buy" th:value="${o.getGID()}">立即下单</a>
						<a href="#" class="goods-buy" th:value="${o.getGID()}">添加到购物车</a>
					</span>
				</figure>
			</ul>
		</div>

			<span class="page-btn">
				<a href="/goToFirstPage.do" class="page-top">首页</a>
				<a href="#" id="last_page" class="page-pre" th:if="${currentPage}!=0" th:value="${currentPage}">上一页</a>
				<a href="#" id="next_page" class="page-next" th:if="${isLastPage}!=true" th:value="${currentPage}">下一页</a>
				<a href="/goToLastPage.do" id="end_page" class="page-end">尾页</a>
			</span>	

	</div>


	<footer>
		<a href="#">©2021-7 二手物品交易</a>
		<a href="#">意见反馈&nbsp;&nbsp;&nbsp;联系我们&nbsp;&nbsp;&nbsp;隐私权声明&nbsp;&nbsp;&nbsp;使用条款</a>
	</footer>

</body>
</html>